package com.zcah.sensitive.common.config;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Component;

import java.io.File;
import java.io.IOException;
import java.net.URI;


//@Configuration
//@Component
//public class HdfsConfig {
////    private static String PATH_TO_HDFS_SITE_XML = "src/main/resources/conf/hdfs-site.xml";
////    private static String PATH_TO_CORE_SITE_XML = "src/main/resources/conf/core-site.xml";
////    private static String PATH_TO_KRB5_CONF = "src/main/resources/conf/admin_krb5.conf";
////    private static String PATH_TO_KEYTAB = "src/main/resources/conf/admin.keytab";
//
//    @Bean(name = "myFileSystem")
//    public FileSystem myFileSystemn() throws IOException {
//        String PATH_TO_CORE_SITE_XML = "src/main/resources/conf/core-site.xml";
//        String PATH_TO_HDFS_SITE_XML = "src/main/resources/conf/hdfs-site.xml";
//        org.apache.hadoop.conf.Configuration hadoopconf = new org.apache.hadoop.conf.Configuration();
//        hadoopconf.addResource(new Path(PATH_TO_HDFS_SITE_XML));
//        hadoopconf.addResource(new Path(PATH_TO_CORE_SITE_XML));
////        System.setProperty("java.security.krb5.conf", PATH_TO_KRB5_CONF);
////        System.setProperty("HADOOP_USER_NAME","master");
//        return FileSystem.get(hadoopconf);
//    }

//    @Bean(name = "myFileSystem")
//    public FileSystem myFileSystem(@Qualifier("hadoopConfig") org.apache.hadoop.conf.Configuration conf) throws IOException {
//        System.out.println("hello");
//        /*if ("kerberos".equalsIgnoreCase(conf.get("hadoop.security.authentication"))) {
//            System.setProperty("java.security.krb5.conf", PATH_TO_KRB5_CONF);
//            LoginUtil.login("admin", PATH_TO_KEYTAB, PATH_TO_KRB5_CONF, conf);
//            return FileSystem.get(conf);
//        } else {
//            System.out.println("null");
//            return null;
//        }*/
//        return FileSystem.get(conf);
//    }

//}
